<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title></title>
		<link href="css/background.css" rel="stylesheet" type="text/css" />
		<link href="css/table.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
		<script type="text/javascript" src="js/openwindow.js"></script>
		<script type="text/javascript" src="js/table.js"></script>
		<script src="js/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
		<script type="text/javascript">
    function dailyNew(id){
     	var url ="dailyNew.action?id="+id
		openWindow(url,550,450);
    }
    function dalilyUpdate(groupId){
    var currentPage=$("#currentPage").val();
		var url="dalilyUpdate.action?id="+groupId+"&currentPage="+currentPage;
		openWindow(url,550,500);
	}
	
	function textadd(){
		var url="dalilySave.action";
		openWindow(url,550,500);
	}
	
	function dailyExcel(){
			var arry="";
			var count=0;
			var checks=$("input[name='ids']");
			for(var i=0;i<checks.length;i++){
				if(checks[i].checked){
					if(arry==''){
					arry+="dalilyId="+checks[i].value;
					}else{
					arry+="&dalilyId="+checks[i].value;
					}
					count++;
				}
			}
			if(count==0){
				alert("请选择要导出的日志！");
				return;
			}
		window.location.href="dalilyExport.action?"+arry;
	}
	function deleteDalily(){
		var arry="";
			var count=0;
			var checks=$("input[name='ids']");
			for(var i=0;i<checks.length;i++){
				if(checks[i].checked){
					if(arry==''){
					arry+="dalilyId="+checks[i].value;
					}else{
					arry+="&dalilyId="+checks[i].value;
					}
					count++;
				}
			}
			if(count==0){
				alert("请选择要删除的数据！");
				return;
			}
			if(confirm("确定要删除？")){
				$.post("deleteDalily.action",arry,function(data){
					if(data=="success"){
						alert("删除数据成功！");
						var currentPage=$("#currentPage").val();
						page(currentPage);
					}else{
						alert("删除数据失败！");
					}
				});
			}
	}
	function page(currentPage){
		$("#pageId").val(currentPage);
		document.pageForm.submit();
	}
	
	function clearall(){
		$("#name").val("");
		$("#startTime1").val("");
	    $("#startTime2").val("");
		document.queryBookForm.submit();
	}
    </script>
	</head>
	<body>
		<div class="topdiv">
			<form action="dailyManager.action" name="queryBookForm" method="post">
				<div>
					内容：
					<input type="text" id="name" name="name" value="${name}" />
					&nbsp;
					开始时间：<input name="startDate"
						value="${startDate }" style="width: 120px;" class="Wdate" id="startTime1" type="text"
						readonly="readonly"
						onclick="WdatePicker({maxDate:'#F{$dp.$D(\'startTime2\',{d:-0});}'})"
						id="startTime1" />
					 &nbsp;结束时间：
					<input  name="endDate" style="width: 120px;" value="${endDate}"
						class="Wdate" id="startTime2" type="text" readonly="readonly"
						onclick="WdatePicker({minDate:'#F{$dp.$D(\'startTime1\',{d:0});}'})"
						id="startTime2" />
				</div>
				<table align="right">
				 <tr>
					<td>
						<input class="button_04" type="submit" value="立即查找" />
				 		<input align="right"  class="button_02" type="button" onclick="clearall()" value="清除" />
					</td>
				 </tr>
				</table>
			</form>
		</div>
		<table border="0" cellpadding="0" cellspacing="0" width="100%">
			<tbody>
				<tr>
					<td style="background: url('image/wsoa_window_002.gif');" width="1"></td>
					<td style="background: url('image/wsoa_window_002.gif');">
						<table border="0" cellpadding="0" cellspacing="0">
							<tbody>
								<tr>
									<td align="center"
										style="background: url('image/wsoa_window_002.gif');"
										width="10">
										<img src="image/center_19.gif">
									</td>
									<td align="center"
										style="background: url('image/wsoa_window_002.gif');"></td>
									<td>
										个人办公 &gt; 工作日志 &gt; 我的日志
									</td>
								</tr>
							</tbody>
						</table>
					</td>
					<td style="background: url('image/wsoa_window_002.gif');" width="1"></td>
				</tr>
				<tr>
					<td style="background: url('image/wsoa_window_010.gif');" width="1">
						&nbsp;
					</td>
					<td>
						<div align="right" style="margin-bottom: 5px; margin-top: 5px">
							<input type="button" onclick="dailyExcel()" value="Excel导出"
										class="button_04" />
							<input type="button" class="button_02" value="添加"
								onclick="textadd()" />
							<input type="button" class="button_02" value="删除"
								onclick="deleteDalily()" />
						</div>
						<table id="tabllist" class="righ_list" frame="box" cellspacing="1"
							cellpadding="0" width="100%" align="center" border="0">
							<tr class="reigh_list2">
								<th width="5%">
									<input onclick="checkAll()" type="checkbox" id="all" />
								</th>
								<th width="10%">
									日期
								</th>
								<th width="10%">
									天气
								</th>
								<th>
									内容
								</th>
								<th width="5%">
									操作
								</th>
							</tr>
							<c:if test="${empty dailyList}">
								<tr id="row">
									<td colspan="5">
										没有相关记录！
									</td>
								</tr>
							</c:if>
							<c:forEach items="${dailyList}" var="daily">
								<tr id="row" onmouseover="overStyle(this)"
									onmouseout="outStyle(this)">
									<td align="center">
										<input type="checkbox" name="ids" value="${daily.id}"
											onclick="checkodd()" />
									</td>
									<td>
										<fmt:formatDate value="${daily.createTime}"
											pattern="yyyy-MM-dd" />
									</td>
									<td>
										${daily.weather }
									</td>
									<td>
										<a href="javascript:dailyNew(${daily.id})">${fn:substring(daily.content,0,35)}</a>
									</td>
									<td align="center">
										<img alt="修改" onclick="dalilyUpdate('${daily.id}')"
											src="image/operate_update.gif" style="cursor: pointer">
									</td>
								</tr>
							</c:forEach>
						</table>
					</td>
					<td style="background: url('image/wsoa_window_006.gif');" width="1">
						&nbsp;
					</td>
				</tr>
				<tr>
					<td height="1" width="1">
						<img src="image/wsoa_window_009.gif" height="16" width="14">
					</td>
					<td style="background: url('image/wsoa_window_008.gif');"
						height="1"></td>
					<td height="1" width="1">
						<img src="image/wsoa_window_007.gif" height="16" width="12">
					</td>
				</tr>
			</tbody>
		</table>
		<div class="pageDiv">
			<form action="dailyManager.action" name="pageForm" method="post">
				<input type="hidden" name="name" id="name" value="${name}" />
				<input type="hidden" name="startDate" value="${startDate}" />
				<input type="hidden" name="endDate" value="${endDate}" />
				<input type="hidden" id="pageId" name="currentPage" />
				<%@include file="../page/page.jsp"%>
			</form>
		</div>
	</body>
</html>
